<template>
	<view>
		<view class="image">
			<swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
						:duration="duration">
						<swiper-item v-for="(item,index) in product.images" :key="index">
							<image class="image"  :src="item.url" :alt="item.title"/>
						</swiper-item>
			</swiper>
		</view>
		<view class="info">
			<view class="title">{{product.name}}</view>
			<view class="price">{{product.price}}</view>
		</view>
		<view class="content">
			<view v-html="product.content"></view>
		</view>
		<view class="goods-carts">
				<uni-goods-nav :options="options" :fill="true" :button-group="buttonGroup" @click="onClick"
						@buttonClick="buttonClick" />
		</view>
	</view>
</template>

<script>
	import {getProduct} from '../../api/index.js'
	export default {
		data() {
			return {
				options: [ {
									icon: 'cart',
									text: '购物车',
									info: 2
								}],
								buttonGroup: [{
										text: '加入购物车',
										backgroundColor: 'linear-gradient(90deg, #FFCD1E, #FF8A18)',
										color: '#fff'
									},
									{
										text: '立即购买',
										backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)',
										color: '#fff'
									}
								],
								customButtonGroup: [{
										text: '加入购物车',
										backgroundColor: 'linear-gradient(90deg, #1E83FF, #0053B8)',
										color: '#fff'
									},
									{
										text: '立即购买',
										backgroundColor: 'linear-gradient(90deg, #60F3FF, #088FEB)',
										color: '#fff'
									}
								],
								customButtonGroup1: [{
									text: '立即购买',
									backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)',
									color: '#fff'
								}],
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				product:{}
			}
		},
		onLoad(option) {
			console.log(option.id)
			if(!option.id) return;
			
			this.getProductInfo(option.id);
		},
		methods: {
			onClick(){
				
			},
			buttonClick(){
				
			},
			getProductInfo(id){
				getProduct({id:id}).then(res=>{
					this.product = res.product
				})
			}
		}
	}
</script>

<style lang="scss">
	.info{
		margin:10upx;
	}
	.prodcut-btn{
		position: fixed;
		width:100%;
		bottom:0upx;
	}
		.goods-carts {
			/* #ifndef APP-NVUE */
			display: flex;
			/* #endif */
			flex-direction: column;
			position: fixed;
			left: 0;
			right: 0;
			/* #ifdef H5 */
			left: var(--window-left);
			right: var(--window-right);
			/* #endif */
			bottom: 0;
		}
	.info{
		height: 225upx;
	}
	.image{
		width:100%;
	}
</style>
